using Common.Communal;
using MediatR;
using Scheduling.Api.Write.Application.Command.ScheduleCommand;
using Scheduling.Services.Schedules;

namespace Scheduling.Api.Write.Application.CommandHandlers.ScheduleHandler
{
    public class ScheduleDelCommandHandler : IRequestHandler<ScheduleDelCommand, ApiResult<int>>
    {
        public ScheduleDelCommandHandler(IScheduleServices scheduleServices)
        {
            ScheduleServices = scheduleServices;
        }

        public IScheduleServices ScheduleServices { get; }

        public async Task<ApiResult<int>> Handle(ScheduleDelCommand request, CancellationToken cancellationToken)
        {
            return await ScheduleServices.DeleteSchedule(request.ScheduleId);
        }
    }
}
